package cn.uexpo.lhz.biz.impl;

import java.util.List;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;



import cn.uexpo.lhz.biz.StaffBiz;
import cn.uexpo.lhz.common.oldBase.BOException;
import cn.uexpo.lhz.common.oldUtils.PageRequest;
import cn.uexpo.lhz.common.oldUtils.PageResult;
import cn.uexpo.lhz.common.oldUtils.PageUtils;
import cn.uexpo.lhz.dao.StaffMapper;
import cn.uexpo.lhz.domain.Staff;
import cn.uexpo.lhz.domain.StaffExample;
import org.springframework.transaction.annotation.Transactional;

@Service
public class StaffBizImpl implements StaffBiz {

	@Autowired
	private StaffMapper staffMapper;

	/**
	 * 单个新增
	 */
	@Override
	public int insert(Staff record) throws BOException {
		return staffMapper.insert(record);
	}

	@Override
	public int insertSelective(Staff record) throws BOException {
		// TODO Auto-generated method stub
		return staffMapper.insertSelective(record);
	}

	@Override
	public int  deleteByPrimaryKey(Integer id) throws BOException {
		// TODO Auto-generated method stub
		return staffMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int deleteEntity(Staff record) throws BOException {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int deleteByIds(List<Integer> ids) throws BOException {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int delete(List<Staff> records) throws BOException {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int deleteByExample(StaffExample example) throws BOException {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int updateByPrimaryKey(Staff record) throws BOException {
		// TODO Auto-generated method stub
		return staffMapper.updateByPrimaryKey(record);
	}

	@Override
	public int updateByPrimaryKeySelective(Staff record) throws BOException {
		// TODO Auto-generated method stub
		return staffMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByExampleSelective(Staff record, StaffExample example) throws BOException {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int updateByExample(Staff record, StaffExample example) throws BOException {
		// TODO Auto-generated method stub
		return 0;
	}

	/**
	 * 根据ID查询
	 */
	@Override
	public Staff selectByPrimaryKey(Integer id) throws BOException {
		return staffMapper.selectByPrimaryKey(id);
	}

	@Override
	public Staff selectByUniqueCode(String uniqueCode) throws BOException {
		// TODO Auto-generated method stub
		return null;
	}

	/**
	 * 查询全部信息，不包括图片
	 */
	@Override
	public List<Staff> selectByExample(StaffExample example) throws BOException {
		return staffMapper.selectByExample(example);
	}

	@Override
	public long countByExample(StaffExample example) throws BOException {
		// TODO Auto-generated method stub
		return 0;
	}

	/**
	 * 分页查询
	 */
	@Override
	public PageResult findPage(PageRequest pageRequest, StaffExample example) throws BOException {
		int pageNum = pageRequest.getPage();
		int pageSize = pageRequest.getLimit();
		PageHelper.startPage(pageNum, pageSize);
		List<Staff> records=(List<Staff>)staffMapper.selectByExampleWithBLOBs(example);
		return PageUtils.getPageResult(pageRequest, new PageInfo<Staff>(records));
	}


	@Override
	public List<Staff> selectByExampleWithBLOBs(StaffExample example) throws BOException {
		return staffMapper.selectByExampleWithBLOBs(example);
	}

	@Override
	public int updateByExampleWithBLOBs(Staff record, StaffExample example) throws BOException {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int updateByPrimaryKeyWithBLOBs(Staff record) throws BOException {
		// TODO Auto-generated method stub
		return staffMapper.updateByPrimaryKeyWithBLOBs(record);
	}

	@Override
	public List<Staff> selectPartStaff(Integer staffId) {
		return staffMapper.selectPartStaff(staffId);
	}

	@Override
	public Staff selectStaffuntitled6(Staff record) {
		return staffMapper.selectStaffuntitled6(record);
	}

	//@Override
	//public List<Staff> findStaffPage(Staff staff) {
	//	// TODO Auto-generated method stub
	//	return staffMapper.findStaffPage(staff);
	//}

	@Override
	public PageResult findStaffPage(PageRequest pageRequest, Staff staff) throws BOException {
		int pageNum = pageRequest.getPage();
		int pageSize = pageRequest.getLimit();
		PageHelper.startPage(pageNum, pageSize);
		List<Staff> records=staffMapper.findStaffPage(staff);
		return PageUtils.getPageResult(pageRequest, new PageInfo<Staff>(records));
	}
	@Override
	public List<Staff>  selectStaffId(Staff record) {
		return staffMapper.selectStaffId(record);
	}

	@Override
	public List<Staff> selectStaffIdWhereProjectName(Staff record) {
		return staffMapper.selectStaffIdWhereProjectName(record);
	}

	@Override
	public List<Staff> selectStaffIdToStaffSingle(Staff record) {
		return staffMapper.selectStaffIdToStaffSingle(record);
	}

	@Override
	public int updateByStaffState(Staff record) {
		return staffMapper.updateByStaffState(record);
	}

	@Override
	public int deleteByStaffIds(List<Integer> staffId) {
		return staffMapper.deleteByIds(staffId);
	}

	@Override
	public int updateByStaffStates(List<Integer> list) {
		return staffMapper.updateByStaffStates(list);
	}

	//查询最大id
	@Override
	public int selectMaxId(StaffExample example) {
		return staffMapper.selectMaxId(example);
	}

	//查询最小id
	@Override
	public int selectMinId(StaffExample example) {
		return staffMapper.selectMinId(example);
	}

	@Override
	public List<Staff> selectStaffIdToStaffNumber(Staff record) {
		return staffMapper.selectStaffIdToStaffNumber(record);
	}



	@Transactional
	@Override
	public int insertBatch(List<Staff> staffList) {
		return staffMapper.insertBatch(staffList);
	}

	@Override
	public int deleteAllByprojectType(String projectType) {
		return staffMapper.deleteAllByprojectType(projectType);
	}


}
